package com.tmt.sms;

import java.util.Map;
import java.util.concurrent.CompletableFuture;

import org.asynchttpclient.Response;
import org.springframework.beans.factory.annotation.Autowired;

import com.swak.annotation.Context;
import com.swak.annotation.FluxService;
import com.swak.http.HttpService;
import com.swak.sms.AbstractSmsService;
import com.tmt.sms.SmsConfigImpl.SceneType;

/**
 * 配置SMS 服务
 * 
 * @author lifeng
 * @date 2020年4月13日 下午4:06:02
 */
@FluxService(context = Context.IO)
public class SmsService extends AbstractSmsService {

	/**
	 * http 服务
	 */
	@Autowired
	private HttpService httpService;
	@Autowired
	private SmsConfigImpl smsConfig;

	@Override
	public HttpService getHttpService() {
		return httpService;
	}

	/**
	 * 发送消息
	 * 
	 * @param type   场景类型
	 * @param phone  手机号
	 * @param params 参数
	 * @return 异步结果
	 */
	public CompletableFuture<Response> send(SceneType type, String phone, Map<String, String> params) {
		return super.send(smsConfig, type, phone, params);
	}
}
